package uk.co.cocking.getinline2.pipeline.transformers;

import java.util.List;

import uk.co.cocking.getinline2.exceptions.EnvironmentException;
import uk.co.cocking.getinline2.pipeline.io.CouldNotProcessRecordException;

public class Bracketer extends AbstractTransformer<String, String> {
	
	private final String preamble;
	private final String postamble;

	public Bracketer(String preamble, String postamble) {
		this.preamble = preamble;
		this.postamble = postamble;
	}

	@Override
	public List<String> open() throws EnvironmentException {
		List<String> oldPreamble = super.open();
		oldPreamble.add(preamble);
		return oldPreamble;
	}

	@Override
	public List<String> close() throws EnvironmentException {
		List<String> oldPostamble = super.open();
		oldPostamble.add(postamble);
		return oldPostamble;
	}


	@Override
	public List<String> transform(String incomingItem)
			throws CouldNotProcessRecordException {
		return enlist(incomingItem);
	}

}
